# Maintainer: Thore Bödecker <foxxx0@archlinux.org>
# Contributor: Tim Meusel <tim@bastelfreak.de>
pkgname="python-pecan"
_pkgname="${pkgname#python-}"
pkgdesc='A WSGI object-dispatching web framework, designed to be lean and fast with few dependencies.'
pkgver=1.4.2
pkgrel=3
arch=('any')
url='https://github.com/pecan/pecan'
license=('BSD')
depends=('python' 'python-webob' 'python-mako' 'python-webtest' 'python-six'
         'python-logutils')
makedepends=('python' 'python-setuptools' 'python-sphinx' 'python-webob'
             'python-mako' 'python-webtest' 'python-six' 'python-logutils')
checkdepends=('python-virtualenv' 'python-jinja' 'gunicorn'
              'python-sqlalchemy' 'python-genshi' 'python-nine' 'uwsgi'
              'python-pytest' 'python-kajiki')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/${_pkgname}/${_pkgname}/archive/${pkgver}.tar.gz")
sha512sums=('2080ba74fc75c458b927b28cbddbe1135da05fd0eff095942823cf43a6d7b03f438a12b46ba007cf45a128628078f3a404842ac2dced86c270b1a1e385feb83b')

prepare(){
  cd "${srcdir}/${_pkgname}-${pkgver}"
  # fix manpage build
  sed -i '/^dist = /d' docs/source/conf.py
  sed -i "s/^version = release = .*\$/version = release = '${pkgver}'/" docs/source/conf.py
}

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  python ./setup.py build
}

check() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  py.test -vvv -s -ra --showlocals --noconftest pecan/tests/
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  python ./setup.py install --root="$pkgdir/" --optimize=1
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

  cd docs
  PYTHONPATH="${PWD}/../" make man
  install -D -m644 "./build/man/pecan.1" "${pkgdir}/usr/share/man/man1/${pkgname}.1"
}
